package com.example.springbootmybatis.service.impl;

import com.example.springbootmybatis.service.RedisService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class RedisServiceImpl implements RedisService {
    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    @Override
    public void set(String key, Object value) {
        ValueOperations<String, Object> valueOper = redisTemplate.opsForValue();
        valueOper.set(key, value);
    }

    @Override
    public Object get(String key) {
        ValueOperations<String, Object> valueOper = redisTemplate.opsForValue();
        return valueOper.get(key);
    }

    @Override
    public void delUser(String uid) {
        redisTemplate.delete(uid);
    }
}
